<?php

/*
 * B端操作功能模块
 * 功能：统计分析
 */

namespace Home\Controller;

use Think\B_Controller;

class AnalyzeController extends B_Controller {
    
    public function __construct() {
        parent::__construct();
    }
    
    public function index(){
        $action_id = (int)$_GET['id'];
        $a = D('Action','Logic');
        $action = $a->getAction($action_id);
        if(!in_array($action['store_id'],$this->store_id)){
            redirect('/home/action');
        }
        //开始统计
        $ana = D('Analyze','Logic');
        $count_order = $ana->countOrder($action_id);
        $mobiles = $ana->getUserMobile($action_id);
        $key_user = $ana->getKeyUser($action_id);
        $latency_user = $ana->getLatencyUser($action_id);
        $table_data = $ana->tableData($action_id);
        $devote_user = $ana->getDevoteUser($action_id);
        $devote_barber = $ana->getDevoteBarber($action_id);
        
        $this->assign('action',$action);
        $this->assign('count_order',$count_order);
        $this->assign('mobiles',$mobiles);
        $this->assign('key_user',$key_user);
        $this->assign('latency_user',$latency_user);
        $this->assign('table_data',$table_data);
        if($action['type'] == 3){//公益活动
            $this->assign('devote_user',$key_user);
        }else{                   //拼团活动
            $this->assign('devote_user',$devote_user);
        }
        $this->assign('devote_barber',$devote_barber);
        
        $this->display('index');
    }
    
}